package com.lemon.lemonai.entity.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.ai.chat.messages.Message;

import static org.springframework.ai.chat.messages.MessageType.ASSISTANT;
import static org.springframework.ai.chat.messages.MessageType.USER;

/**
 * @Description: 前端需要[{role:"user", content:""}]这样的消息格式
 * @Author: lemon
 * @CreateTime: 2025-03-22  21:59
 * @Version: 1.0
 */
@Data
@NoArgsConstructor
public class MessageVO {

    //对话的角色
    private String role;

    //对话的内容
    private String content;

    public MessageVO(Message message){
        this.role = switch (message.getMessageType()) {
            case USER -> USER.getValue();
            case ASSISTANT -> ASSISTANT.getValue();
            default ->  "";
        };
        this.content = message.getText();
    }
}
